﻿using Oracle.ManagedDataAccess.Client;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web.Http;

namespace Waiyun.WebApi
{
    public class ITMaintController : ApiController
    {
        public static string ConnectionString;

        static ITMaintController()
        {
            ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["weitsm_orcl"].ConnectionString;
        }

        /*
         [
 {"leftData":[
    {"name":"备份平台","value":276},
    {"name":"公共应用类","value":238},
    {"name":"EDI平台","value":176},
    {"name":"管理应用类","value":173},
    {"name":"VPN网络","value":173},
    {"name":"数据中心机房","value":98},
    {"name":"数据中心核心网络","value":75},
    {"name":"财务系统","value":51.0}
    
   ]
},
 {"right0":
  {"ledgend":["防病毒系统0","邮件系统","代理服务器","DNS服务"],
  "data":[22,46,100,2]
  }
 },
 {"right1":
  {"ledgend":["邮件系统1","代理服务器","DNS服务","邮件系统"],
  "data":[12,41,100,20]
  }
 },
 {"right2":
  {"ledgend":["防病毒系统2","代理服务器","DNS服务","邮件系统"],
  "data":[98,32,43,120]
  }
 },
 {"right3":
  {"ledgend":["防病毒系统3","邮件系统","代理服务器","DNS服务"],
  "data":[22,6,10,33]
  }
 },
 {"right4":
  {"ledgend":["防病毒系统","邮件系统","代理服务器","DNS服务"],
  "data":[122,46,100,12]
  }
 },
 {"right5":
  {"ledgend":["防病毒系统","邮件系统","代理服务器","DNS服务"],
  "data":[232,46,100,32]
  }
 },
 {"right6":
  {"ledgend":["防病毒系统","邮件系统","代理服务器","DNS服务"],
  "data":[292,146,100,12]
  }
 },
 {"right7":
  {"ledgend":["防病毒系统","邮件系统","代理服务器","DNS服务"],
  "data":[562,446,10,2]
  }
 }
 
]*/
        [HttpGet]
        public object[] DS001()
        {
            OracleConnection connection = new OracleConnection(ConnectionString);
            try
            {
                connection.Open();


                List<object> result = new List<object>();

                using (OracleCommand alterCmd = new OracleCommand("alter session set current_schema=eshell", connection))
                {
                    alterCmd.ExecuteNonQuery();
                }
                using (OracleCommand command = new OracleCommand(@"select t.it02_cls_id1, t2.it01_name, count(*) StatCount
  from it02_incidant_base t, it01_incidant_cls t2
 where t.it02_cls_id1 = t2.it01_class_id
   and t.it02_ent_id = 10134
   and t.it02_status NOT IN ('BD0901')
   and TO_CHAR(t.IT02_CRT_TIME, 'yyyymm') = TO_CHAR(SYSDATE, 'yyyymm')
 group by t.it02_cls_id1, t2.it01_name order by statcount desc", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(command);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    DS001LeftData leftData = new DS001LeftData();

                    int leftDataItemCount = 8;
                    if (dataTable.Rows.Count < leftDataItemCount)
                    {
                        leftDataItemCount = dataTable.Rows.Count;
                    }
                    leftData.leftData = new NVItem[leftDataItemCount];
                    result.Add(leftData);
                    for (int index = 0; index < dataTable.Rows.Count && index < leftDataItemCount; index++)
                    {
                        string it02_cls_id1 = Convert.ToString(dataTable.Rows[index]["it02_cls_id1"]);
                        string it01_name = Convert.ToString(dataTable.Rows[index]["it01_name"]);
                        decimal statCount = Convert.ToDecimal(dataTable.Rows[index]["StatCount"]);
                        leftData.leftData[index] = new NVItem()
                        {
                            name = it01_name,
                            value = statCount
                        };

                        using (OracleCommand subCmd = new OracleCommand(string.Format(@"select t.it02_cls_id2, t2.it01_name, count(*) StatCount
  from it02_incidant_base t, it01_incidant_cls t2
 where t.it02_cls_id2 = t2.it01_class_id
   and t.it02_ent_id = 10134
   and t.it02_status NOT IN ('BD0901')
   and TO_CHAR(t.IT02_CRT_TIME, 'yyyymm') = TO_CHAR(SYSDATE, 'yyyymm')
   and t2.it01_father_id = '{0}'
 group by t.it02_cls_id2, t2.it01_name  order by statcount desc", it02_cls_id1), connection))
                        {
                            OracleDataAdapter subAdapter = new OracleDataAdapter(subCmd);
                            DataTable subDataTable = new DataTable();
                            subAdapter.Fill(subDataTable);

                            Dictionary<string, DS001RightData> right = new Dictionary<string, DS001RightData>();
                            result.Add(right);

                            DS001RightData rightData = new DS001RightData();
                            int rightDataItemCount = 4;
                            if (subDataTable.Rows.Count < rightDataItemCount)
                            {
                                rightDataItemCount = subDataTable.Rows.Count;
                            }
                            rightData.ledgend = new string[rightDataItemCount];
                            rightData.data = new decimal[rightDataItemCount];
                            right.Add(string.Format("right{0}", index), rightData);
                            for (int subIndex = 0; subIndex < rightDataItemCount; subIndex++)
                            {
                                string subit02_cls_id2 = Convert.ToString(subDataTable.Rows[subIndex]["it02_cls_id2"]);
                                string subit01_name = Convert.ToString(subDataTable.Rows[subIndex]["it01_name"]);
                                decimal substatCount = Convert.ToDecimal(subDataTable.Rows[subIndex]["StatCount"]);
                                rightData.ledgend[subIndex] = subit01_name;
                                rightData.data[subIndex] = substatCount;
                            }
                        }
                    }

                    //Cache.Set("WTSLD-XYWARN", data);
                    return result.ToArray();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }

        [HttpGet]
        public DS002Result DS002()
        {
            OracleConnection connection = new OracleConnection(ConnectionString);
            try
            {
                connection.Open();

                DS002Result result = new DS002Result();

                using (OracleCommand alterCmd = new OracleCommand("alter session set current_schema=eshell", connection))
                {
                    alterCmd.ExecuteNonQuery();
                }
                using (OracleCommand command = new OracleCommand(@"select SUM(DECODE(nvl(t.IT02_STS_SLA_2,'IT0201'),'IT0203',1,0)) TimeoutCount,
       count(*) as TotalCount
  from it02_incidant_base t
 where t.it02_ent_id = 10134
   and t.it02_status IN ('BD0906', 'BD0907')
   and TO_CHAR(t.IT02_CRT_TIME, 'YYYY-MM-DD') >
       TO_CHAR(ADD_MONTHS(TRUNC(SYSDATE), -1), 'YYYY-MM-DD')", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(command);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);
                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        decimal TimeoutCount = Convert.ToDecimal(dataTable.Rows[index]["TimeoutCount"]);
                        decimal TotalCount = Convert.ToDecimal(dataTable.Rows[index]["TotalCount"]);
                        result.及时响应率 = string.Format("{0:#0.00}%", (TotalCount - TimeoutCount) / TotalCount * 100.0m);
                        break;
                    }
                }

                using (OracleCommand subCmd = new OracleCommand(@"select SUM(DECODE(nvl(t.IT02_STS_SLA_3,'IT0201'),'IT0203',1,0)) TimeoutCount,
       count(*) as TotalCount
  from it02_incidant_base t
 where t.it02_ent_id = 10134
   and t.it02_status IN ('BD0906', 'BD0907')
   and TO_CHAR(t.IT02_CRT_TIME, 'YYYY-MM-DD') >
       TO_CHAR(ADD_MONTHS(TRUNC(SYSDATE), -1), 'YYYY-MM-DD')", connection))
                {
                    OracleDataAdapter subAdapter = new OracleDataAdapter(subCmd);
                    DataTable subDataTable = new DataTable();
                    subAdapter.Fill(subDataTable);

                    for (int subIndex = 0; subIndex < subDataTable.Rows.Count; subIndex++)
                    {
                        decimal TimeoutCount = Convert.ToDecimal(subDataTable.Rows[subIndex]["TimeoutCount"]);
                        decimal TotalCount = Convert.ToDecimal(subDataTable.Rows[subIndex]["TotalCount"]);
                        result.及时解决率 = string.Format("{0:#0.00}%", (TotalCount - TimeoutCount) / TotalCount * 100.0m);
                        break;
                    }
                }

                //Cache.Set("WTSLD-XYWARN", data);
                return result;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }

        /*[{
    "name": "财务系统组",
 "data": [
  [54.49,418.74,93.0]
 ]
},
{
    "name": "客户端运维组",
  "data": [
  [48.38,0.71,545.0]
 ]
}]
 数组的第一个表示平均处理时长，第二个表示平均响应时长，第三个表示事件量*/
        [HttpGet]
        public DS003Result[] DS003()
        {
            OracleConnection connection = new OracleConnection(ConnectionString);
            try
            {
                connection.Open();

                using (OracleCommand alterCmd = new OracleCommand("alter session set current_schema=eshell", connection))
                {
                    alterCmd.ExecuteNonQuery();
                }
                using (OracleCommand command = new OracleCommand(@"select t.it02_assigned_grp,
       t2.hra6_grp_name_1,
       count(*) StatCount,
       sum(nvl(t.IT02_RESOLUTION_TIME, 0)) as RESOLUTION_TIME,
       sum(nvl(t.it02_response_time, 0)) as response_time
  from it02_incidant_base t, hra6_working_grp_def t2
 where t.it02_assigned_grp = t2.hra6_grp_id
   and t.it02_ent_id = 10134
   and t.it02_status IN ('BD0906', 'BD0907')
   and TO_CHAR(t.IT02_CRT_TIME, 'YYYY-MM-DD') >
       TO_CHAR(ADD_MONTHS(TRUNC(SYSDATE), -1), 'YYYY-MM-DD')
 group by t.it02_assigned_grp, t2.hra6_grp_name_1", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(command);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    DS003Result[] result = new DS003Result[dataTable.Rows.Count];
                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        string it02_assigned_grp = Convert.ToString(dataTable.Rows[index]["it02_assigned_grp"]);
                        string hra6_grp_name_1 = Convert.ToString(dataTable.Rows[index]["hra6_grp_name_1"]);
                        decimal StatCount = Convert.ToDecimal(dataTable.Rows[index]["StatCount"]);
                        decimal RESOLUTION_TIME = Convert.ToDecimal(dataTable.Rows[index]["RESOLUTION_TIME"]);
                        decimal response_time = Convert.ToDecimal(dataTable.Rows[index]["response_time"]);

                        DS003Result data = new DS003Result();
                        data.data = new decimal[3];
                        if (RESOLUTION_TIME == 0)
                        {
                            data.data[0] = 0;
                        }
                        else
                        {
                            data.data[0] = Math.Round(StatCount / RESOLUTION_TIME * 1000.0m, 2);
                        }
                        if (response_time == 0)
                        {
                            data.data[1] = 0;
                        }
                        else
                        {
                            data.data[1] = Math.Round(StatCount / response_time * 1000.0m, 2);
                        }
                        data.data[2] = StatCount;
                        data.name = hra6_grp_name_1;

                        result[index] = data;
                    }
                    return result;
                }

                //Cache.Set("WTSLD-XYWARN", data);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }

        /*
{	
	"xAxis":["网络运维组","EDI"],
	"data1": [ 50,75 ],
	"data2":[50,25],
	"allCount":[300,500]
}*/
        [HttpGet]
        public DS004Result DS004()
        {
            OracleConnection connection = new OracleConnection(ConnectionString);
            try
            {
                connection.Open();

                DS004Result result = new DS004Result();
                using (OracleCommand alterCmd = new OracleCommand("alter session set current_schema=eshell", connection))
                {
                    alterCmd.ExecuteNonQuery();
                }
                using (OracleCommand command = new OracleCommand(@"select t.it02_cls_id1,
       t2.it01_name,
       sum(case when nvl(t.IT02_STS_SLA_3, 'IT0201')='IT0203' OR nvl(t.IT02_STS_SLA_2, 'IT0201')='IT0203' then 1 else 0 end) TimeoutCount,
       sum(case when nvl(t.IT02_STS_SLA_3, 'IT0201')='IT0203' OR nvl(t.IT02_STS_SLA_2, 'IT0201')='IT0203' then 0 else 1 end) NotTimeoutCount,
       count(*) TotalCount
  from it02_incidant_base t, it01_incidant_cls t2
 where t.it02_cls_id1 = t2.it01_class_id
   and t.it02_ent_id = 10134
   and t.it02_status IN ('BD0906', 'BD0907')
   and TO_CHAR(t.IT02_CRT_TIME, 'YYYY-MM-DD') >
       TO_CHAR(ADD_MONTHS(TRUNC(SYSDATE), -1), 'YYYY-MM-DD')
   and t.it02_assigned_grp in('fb034bece0294778ac531080db1c8151','119E74EEEB71423BA69353BF2F41BDF2')
 group by t.it02_cls_id1, t2.it01_name", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(command);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    // data1未超时,data2超时
                    result.xAxis = new string[dataTable.Rows.Count];
                    result.data1 = new decimal[dataTable.Rows.Count];
                    result.data2 = new decimal[dataTable.Rows.Count];
                    result.allCount = new decimal[dataTable.Rows.Count];
                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        string it02_cls_id1 = Convert.ToString(dataTable.Rows[index]["it02_cls_id1"]);
                        string it01_name = Convert.ToString(dataTable.Rows[index]["it01_name"]);
                        decimal TimeoutCount = Convert.ToDecimal(dataTable.Rows[index]["TimeoutCount"]);
                        decimal NotTimeoutCount = Convert.ToDecimal(dataTable.Rows[index]["NotTimeoutCount"]);
                        decimal TotalCount = Convert.ToDecimal(dataTable.Rows[index]["TotalCount"]);


                        result.xAxis[index] = it01_name;
                        result.data1[index] = Math.Round((NotTimeoutCount / TotalCount * 100.0m), 2);
                        result.data2[index] = 100.0m - result.data1[index];
                        result.allCount[index] = TotalCount;
                    }
                }

                //Cache.Set("WTSLD-XYWARN", data);
                return result;
            }
            catch (Exception ex)
            {
                DS004Result result = new DS004Result();
                return result;
            }
            finally
            {
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }

        /*
         * "满意度":{
  "data": [
  {
   "value": 345,
   "name": "非常满意"
  }, 
  {
   "value": 210,
   "name": "十分满意"
  }, 
  {
   "value": 134,
   "name": "满意"
  }, 
  {
   "value": 65,
   "name": "不满意"
  }
  ]
 }*/
        [HttpGet]
        public DS005Result DS005()
        {
            OracleConnection connection = new OracleConnection(ConnectionString);
            try
            {
                connection.Open();

                DS005Result result = new DS005Result();
                result.满意度 = new DS005Data();

                using (OracleCommand alterCmd = new OracleCommand("alter session set current_schema=eshell", connection))
                {
                    alterCmd.ExecuteNonQuery();
                }
                using (OracleCommand command = new OracleCommand(@"select t.IT02_USR_SATISFACTION,t2.ss09_val_name, count(*) StatCount
  from it02_incidant_base t,ss09_usr_dict_values t2
 where t.IT02_USR_SATISFACTION=t2.ss09_value_id 
   and t.it02_ent_id = 10134
   and t.it02_status IN ('BD0907')
   and TO_CHAR(t.IT02_CRT_TIME, 'YYYY-MM-DD') >
       TO_CHAR(ADD_MONTHS(TRUNC(SYSDATE), -1), 'YYYY-MM-DD')
 group by t.IT02_USR_SATISFACTION,t2.ss09_val_name", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(command);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    result.满意度.data = new NVItem[dataTable.Rows.Count];
                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        string ss09_val_name = Convert.ToString(dataTable.Rows[index]["ss09_val_name"]);
                        decimal StatCount = Convert.ToDecimal(dataTable.Rows[index]["StatCount"]);

                        NVItem item = new NVItem();
                        item.name = ss09_val_name;
                        item.value = StatCount;
                        result.满意度.data[index] = item;
                    }
                }

                //Cache.Set("WTSLD-XYWARN", data);
                return result;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }

        /*
         "单量":{
  "昨日事件单量":300,
  "今日事件单量":290
 }
         * */
        [HttpGet]
        public DS006Result DS006()
        {
            OracleConnection connection = new OracleConnection(ConnectionString);
            try
            {
                connection.Open();

                DS006Result result = new DS006Result();
                result.单量 = new DS006Content();

                using (OracleCommand alterCmd = new OracleCommand("alter session set current_schema=eshell", connection))
                {
                    alterCmd.ExecuteNonQuery();
                }
                using (OracleCommand cmd1 = new OracleCommand(@"select count(*)
  from it02_incidant_base t
 where t.it02_ent_id = 10134
  and t.it02_status not IN ('BD0901', 'BD0999')
  -- and t.it02_status IN ('BD0906', 'BD0907')
   and TO_CHAR(t.IT02_CRT_TIME, 'yyyymmdd') =
       TO_CHAR((TRUNC(SYSDATE) - 1), 'yyyymmDD')", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd1);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        decimal value = Convert.ToDecimal(dataTable.Rows[index][0]);

                        result.单量.昨日事件单量 = value;
                        break;
                    }
                }
                using (OracleCommand cmd2 = new OracleCommand(@"select count(*)
          from it02_incidant_base t
         where t.it02_ent_id = 10134
           and t.it02_status not IN ('BD0901', 'BD0999')
           and TO_CHAR(t.IT02_CRT_TIME, 'yyyymmdd') =
               TO_CHAR(SYSDATE, 'yyyymmdd')", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd2);
                    DataTable dataTable2 = new DataTable();
                    adapter.Fill(dataTable2);

                    for (int index = 0; index < dataTable2.Rows.Count; index++)
                    {
                        decimal value = Convert.ToDecimal(dataTable2.Rows[index][0]);

                        result.单量.今日事件单量 = value;
                        break;
                    }
                }

                //Cache.Set("WTSLD-XYWARN", data);
                return result;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }

        /*
         * "事件处理流程":{
  "待分派":200,
  "待受理":200,
  "进行中":200,
  "已解决":200
 },*/
        [HttpGet]
        public DS007Result DS007()
        {
            OracleConnection connection = new OracleConnection(ConnectionString);
            try
            {
                connection.Open();

                DS007Result result = new DS007Result();
                result.事件处理流程 = new Dictionary<string, decimal>();

                using (OracleCommand alterCmd = new OracleCommand("alter session set current_schema=eshell", connection))
                {
                    alterCmd.ExecuteNonQuery();
                }
                using (OracleCommand cmd1 = new OracleCommand(@"select 
       sum(DECODE(T.it02_status,'BD0902',1,0)) AS Count1,
       sum(DECODE(T.it02_status,'BD0903',1,0)) AS Count2,
       sum(DECODE(T.it02_status,'BD0904',1,'BD0905',1,'BD0920',1,0)) AS Count3,
       sum(DECODE(T.it02_status,'BD0906',1,'BD0907',1,0)) AS Count4
  from it02_incidant_base t
 where t.it02_ent_id = 10134
    and TO_CHAR(t.IT02_CRT_TIME, 'YYYY-MM-DD') >TO_CHAR(SYSDATE-1, 'YYYY-MM-DD')", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd1);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        decimal Count1 = Convert.ToDecimal(dataTable.Rows[index]["Count1"]);
                        decimal Count2 = Convert.ToDecimal(dataTable.Rows[index]["Count2"]);
                        decimal Count3 = Convert.ToDecimal(dataTable.Rows[index]["Count3"]);
                        decimal Count4 = Convert.ToDecimal(dataTable.Rows[index]["Count4"]);

                        result.事件处理流程.Add("待分派", Count1);
                        result.事件处理流程.Add("待受理", Count2);
                        result.事件处理流程.Add("进行中", Count3);
                        result.事件处理流程.Add("已解决", Count4);
                        break;
                    }
                }
                return result;
            }
            catch (Exception ex)
            {
                DS007Result result = new DS007Result();
                result.事件处理流程 = new Dictionary<string, decimal>();
                result.事件处理流程.Add("待分派", 0);
                result.事件处理流程.Add("待受理", 0);
                result.事件处理流程.Add("进行中", 0);
                result.事件处理流程.Add("已解决", 0);
                return result;
            }
            finally
            {
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }

        /*
         { 
 "left1":{
  "count":200,
  "percent":"40%"
 },"left2":{
  "product":"54%",
  "operation":"46%"
 }}
         * */
        [HttpGet]
        public DS008Result DS008()
        {
            OracleConnection connection = new OracleConnection(ConnectionString);
            try
            {
                connection.Open();

                DS008Result result = new DS008Result();
                result.right = new DS008Result.Right();
                result.left = new DS008Result.Left();

                using (OracleCommand alterCmd = new OracleCommand("alter session set current_schema=eshell", connection))
                {
                    alterCmd.ExecuteNonQuery();
                }
                using (OracleCommand cmd1 = new OracleCommand(@"select sum(decode(t.ss11_usr_class,'e8d6cec1747b44df8e914032254da731',1,0)) as Count1,
       Count(*) TotalCount
  from ss11_sys_users t
 where ss11_status = 'BD0902'
   and ss11_ent_id = 10134", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd1);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        decimal TotalCount = Convert.ToDecimal(dataTable.Rows[index]["TotalCount"]);
                        result.left.count = TotalCount;
                        break;
                    }
                }
                using (OracleCommand cmd2 = new OracleCommand(@"select sum(decode(t.ss11_usr_class,'e8d6cec1747b44df8e914032254da731',1,0)) as Count1,
       Count(*) TotalCount
  from ss11_sys_users t
 where ss11_status = 'BD0902'
   and ss11_ent_id = 10134", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd2);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        decimal Count1 = Convert.ToDecimal(dataTable.Rows[index]["Count1"]);
                        decimal TotalCount = Convert.ToDecimal(dataTable.Rows[index]["TotalCount"]);
                        result.left.percent = string.Format("{0}%", (int)(Count1 / TotalCount * 100.0m));
                        break;
                    }
                }
                using (OracleCommand cmd3 = new OracleCommand(@"select nvl(t.it02_obj_code, 'OBJ_INCIDANT_BASE') ObjCode,
       count(*) StatCount
  from it02_incidant_base t
 where t.it02_ent_id = 10134   
     and t.it02_status  IN ('BD0903','BD0904','BD0906','BD0907')
   and TO_CHAR(t.IT02_CRT_TIME, 'YYYY-MM-DD') >
       TO_CHAR(ADD_MONTHS(TRUNC(SYSDATE), -1), 'YYYY-MM-DD')
 group by nvl(t.it02_obj_code, 'OBJ_INCIDANT_BASE')", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd3);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    decimal OBJ_INCIDANT_BASE = 0;
                    decimal OBJ_IT_MONITOR = 0;
                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        string ObjCode = Convert.ToString(dataTable.Rows[index]["ObjCode"]);
                        decimal StatCount = Convert.ToDecimal(dataTable.Rows[index]["StatCount"]);
                        if (string.Equals(ObjCode, "OBJ_INCIDANT_BASE", StringComparison.CurrentCultureIgnoreCase))
                        {
                            OBJ_INCIDANT_BASE = StatCount;
                        }
                        else if (string.Equals(ObjCode, "OBJ_IT_MONITOR", StringComparison.CurrentCultureIgnoreCase))
                        {
                            OBJ_IT_MONITOR = StatCount;
                        }
                    }

                    if (OBJ_INCIDANT_BASE == 0)
                    {
                        result.right.product = "0%";
                        result.right.operation = "0%";
                    }
                    else
                    {
                        result.right.product = string.Format("{0}%", (int)(OBJ_IT_MONITOR / OBJ_INCIDANT_BASE * 100.0m));
                        result.right.operation = string.Format("{0}%",  100 - (int)(OBJ_IT_MONITOR / OBJ_INCIDANT_BASE * 100.0m));
                    }
                }
                return result;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }

        /*
         * { 
 
 "count":200,
  "month":200,
  "week":70
 }
         * */
        [HttpGet]
        public DS009Result DS009()
        {
            OracleConnection connection = new OracleConnection(ConnectionString);
            try
            {
                connection.Open();

                DS009Result result = new DS009Result();

                using (OracleCommand alterCmd = new OracleCommand("alter session set current_schema=eshell", connection))
                {
                    alterCmd.ExecuteNonQuery();
                }
                using (OracleCommand cmd1 = new OracleCommand(@"select count(*)
  from it02_incidant_base t
 where t.it02_ent_id = 10134
   and t.it02_status IN ('BD0906', 'BD0907')", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd1);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        decimal TotalCount = Convert.ToDecimal(dataTable.Rows[index][0]);
                        result.count = TotalCount;
                        break;
                    }
                }
                using (OracleCommand cmd2 = new OracleCommand(@"select count(*)
  from it02_incidant_base t
 where t.it02_ent_id = 10134
   and t.it02_status not IN ('BD0901', 'BD0999')
   and TO_CHAR(t.IT02_CRT_TIME, 'yyyymm') = TO_CHAR(SYSDATE,'yyyymm')", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd2);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        decimal Count1 = Convert.ToDecimal(dataTable.Rows[index][0]);
                        result.month = Count1;
                        break;
                    }
                }
                using (OracleCommand cmd3 = new OracleCommand(@"select count(*)
  from it02_incidant_base t
 where t.it02_ent_id = 10134
   and t.it02_status not IN ('BD0901', 'BD0999')   and TO_CHAR(t.IT02_CRT_TIME, 'yyyyww') = TO_CHAR(SYSDATE, 'yyyyww')", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd3);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        decimal StatCount = Convert.ToDecimal(dataTable.Rows[index][0]);
                        result.week = StatCount;
                        break;
                    }
                }
                return result;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }

        /*
          [ {
   "value": 335,
   "name": "网络"
  }, {
   "value": 310,
   "name": "专业物流"
  }, {
   "value": 234,
   "name": "公共应用"
  }, {
   "value": 135,
   "name": "终端及外设"
  }, {
   "value": 148,
   "name": "EDI"
  }
 ]
         * */
        [HttpGet]
        public NVItem[] DS010()
        {
            OracleConnection connection = new OracleConnection(ConnectionString);
            try
            {
                connection.Open();

                using (OracleCommand alterCmd = new OracleCommand("alter session set current_schema=eshell", connection))
                {
                    alterCmd.ExecuteNonQuery();
                }
                using (OracleCommand cmd1 = new OracleCommand(@"select t.it02_cls_id2, t2.it01_name, count(*) StatCount
  from it02_incidant_base t, it01_incidant_cls t2
 where t.it02_cls_id2 = t2.it01_class_id
   and t.it02_ent_id = 10134
   and t.it02_status NOT IN ('BD0901')
   and nvl(t.it02_obj_code, 'OBJ_INCIDANT_BASE') != 'OBJ_IT_MONITOR'
   and TO_CHAR(t.IT02_CRT_TIME, 'YYYY-MM-DD') >
       TO_CHAR(ADD_MONTHS(TRUNC(SYSDATE), -1), 'YYYY-MM-DD')
 group by t.it02_cls_id2, t2.it01_name
 order by statcount desc", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd1);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    NVItem[] result = new NVItem[10];
                    for (int index = 0; index < dataTable.Rows.Count && index < 10; index++)
                    {
                        string it01_name = Convert.ToString(dataTable.Rows[index]["it01_name"]);
                        decimal StatCount = Convert.ToDecimal(dataTable.Rows[index]["StatCount"]);
                        NVItem item = new NVItem();
                        item.name = it01_name;
                        item.value = StatCount;
                        result[index] = item;
                    }
                    return result;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }

        /*
        { "allCount":1823,
 "data1":[43, 30, 26, 18,20],
 "data2":[ 10,15,14,13,22],
 "ledgend":["网络", "机房组", "监控组", "桌面组","EDI"]
}
         */
        [HttpGet]
        public DS011Result DS011()
        {
            OracleConnection connection = new OracleConnection(ConnectionString);
            try
            {
                connection.Open();
                DS011Result result = new DS011Result();

                using (OracleCommand alterCmd = new OracleCommand("alter session set current_schema=eshell", connection))
                {
                    alterCmd.ExecuteNonQuery();
                }
                using (OracleCommand cmd1 = new OracleCommand(@"select t.it02_assigned_grp, t2.hra6_grp_name_1,
  sum(DECODE(T.it02_status,'BD0902',1,'BD0903',1,'BD0904',1,'BD0905',1,'BD0920',1,0)) AS NotOKCount,
  sum(DECODE(T.it02_status,'BD0906',1,'BD0907',1,0)) AS OKCount,
  count(*) as TotalCount
  from it02_incidant_base t, hra6_working_grp_def t2
 where t.it02_assigned_grp = t2.hra6_grp_id
   and t.it02_ent_id = 10134
   and t.it02_status NOT IN ('BD0901', 'BD0999')
   and nvl(t.it02_obj_code, 'OBJ_INCIDANT_BASE') != 'OBJ_IT_MONITOR'
   and TO_CHAR(t.IT02_CRT_TIME, 'YYYY-MM-DD') >
       TO_CHAR(ADD_MONTHS(TRUNC(SYSDATE), -1), 'YYYY-MM-DD')
 group by t.it02_assigned_grp, t2.hra6_grp_name_1 order by totalcount desc", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd1);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    result.ledgend = new string[dataTable.Rows.Count];
                    result.data1 = new decimal[dataTable.Rows.Count];
                    result.data2 = new decimal[dataTable.Rows.Count];

                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        string hra6_grp_name_1 = Convert.ToString(dataTable.Rows[index]["hra6_grp_name_1"]);
                        decimal OKCount = Convert.ToDecimal(dataTable.Rows[index]["OKCount"]);
                        decimal NotOKCount = Convert.ToDecimal(dataTable.Rows[index]["NotOKCount"]);

                        result.ledgend[index] = hra6_grp_name_1;
                        result.data1[index] = OKCount;
                        result.data2[index] = NotOKCount;
                        result.allCount += Convert.ToDecimal(dataTable.Rows[index]["TotalCount"]);

                    }
                }
                return result;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }

        /*
         *[
 {
 "value":535,
 "name":"总数"
 },
    {
 "value":44, 
 "name":"外协"
    }
]
         * */
        [HttpGet]
        public NVItem[] DS012()
        {
            OracleConnection connection = new OracleConnection(ConnectionString);
            try
            {
                connection.Open();
                using (OracleCommand alterCmd = new OracleCommand("alter session set current_schema=eshell", connection))
                {
                    alterCmd.ExecuteNonQuery();
                }
                decimal total = 0;
                decimal outSourcing = 0;
                using (OracleCommand cmd1 = new OracleCommand(@" select t2.ss11_usr_class, count(*) StatCount
  from it02_incidant_base t, ss11_sys_users t2
 where t.it02_assignee = t2.ss11_usr_id
   and t.it02_ent_id = 10134
   and t.it02_status  IN ('BD0904','BD0906','BD0907')
   and TO_CHAR(t.IT02_CRT_TIME, 'YYYY-MM-DD') >
       TO_CHAR(ADD_MONTHS(TRUNC(SYSDATE), -1), 'YYYY-MM-DD')
 group by t2.ss11_usr_class", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd1);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);


                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        string ss11_usr_class = Convert.ToString(dataTable.Rows[index]["ss11_usr_class"]);
                        decimal StatCount = Convert.ToDecimal(dataTable.Rows[index]["StatCount"]);
                        if (string.Equals(ss11_usr_class, "e8d6cec1747b44df8e914032254da731", StringComparison.CurrentCultureIgnoreCase))
                        {
                            outSourcing = StatCount;
                        }
                        total += StatCount;
                    }
                }
                NVItem[] result = new NVItem[2];
                result[0] = new NVItem()
                {
                    name="全数",
                    value = total
                };
                result[1] = new NVItem()
                {
                    name = "外协",
                    value = outSourcing
                };
                return result;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }

        /*
         [{
    "name": "EDI",
 "data": [80,100]
},{
    "name": "EDI2",
 "data": [81,100]
}]
         */
        [HttpGet]
        public DS003Result[] DS013()
        {
            OracleConnection connection = new OracleConnection(ConnectionString);
            try
            {
                connection.Open();
                using (OracleCommand alterCmd = new OracleCommand("alter session set current_schema=eshell", connection))
                {
                    alterCmd.ExecuteNonQuery();
                }

                using (OracleCommand cmd1 = new OracleCommand(@"select t3.hra6_grp_id,
       t3.hra6_grp_name_1,
       sum(decode(t2.ss11_usr_class,'e8d6cec1747b44df8e914032254da731',1,0)) as Count1,
       count(*) StatCount
  from it02_incidant_base t, ss11_sys_users t2, hra6_working_grp_def t3
 where t.it02_assignee = t2.ss11_usr_id
   and t.it02_assigned_grp = t3.hra6_grp_id
   and t.it02_ent_id = 10134
   and t.it02_status IN ('BD0906', 'BD0907')
and TO_CHAR(t.IT02_CRT_TIME,'YYYY-MM-DD') >TO_CHAR(ADD_MONTHS(TRUNC(SYSDATE),-1),'YYYY-MM-DD') 
 group by t3.hra6_grp_id, t3.hra6_grp_name_1", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd1);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    DS003Result[] result = new DS003Result[dataTable.Rows.Count];
                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        string hra6_grp_name_1 = Convert.ToString(dataTable.Rows[index]["hra6_grp_name_1"]);
                        decimal Count1 = Convert.ToDecimal(dataTable.Rows[index]["Count1"]);
                        decimal StatCount = Convert.ToDecimal(dataTable.Rows[index]["StatCount"]);

                        DS003Result data = new DS003Result();
                        data.data = new decimal[2];
                        data.data[0] = Convert.ToInt32(Count1 / StatCount * 100.0m);
                        data.data[1] = StatCount;
                        data.name = hra6_grp_name_1;
                        result[index] = data;
                    }
                    return result;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }

        /*
        {
 "financialSystem":{
  "lastmonth":[200, 103, 143,323, 273, 346, 144, 166, 122,
     132, 121, 134,200, 260, 110, 112,101, 292, 250,
     120,300,160,80, 100,230, 130, 100, 320, 110],
  "thismonth":[200, 103, 143,323, 273, 346, 144, 166, 122,
     132, 121, 134,200, 260, 110, 112,101, 292, 250,
     120,300,160,80, 100,230, 130, 100, 320, 110]
 },
 "dasktop":{
  "lastmonth":[200, 103, 143,323, 273, 346, 144, 166, 122,
     132, 121, 134,200, 260, 110, 112,101, 292, 250,
     120,300,160,80, 100,230, 130, 100, 320, 110],
  "thismonth":[200, 103, 143,323, 273, 346, 144, 166, 122,
     132, 121, 134,200, 260, 110, 112,101, 292, 250,
     120,300,160,80, 100,230, 130, 100, 320, 110]
 },
 "EDI":{
  "lastmonth":[200, 103, 143,323, 273, 346, 144, 166, 122,
     132, 121, 134,200, 260, 110, 112,101, 292, 250,
     120,300,160,80, 100,230, 130, 100, 320, 110],
  "thismonth":[200, 103, 143,323, 273, 346, 144, 166, 122]
 } 
}
         * */
        [HttpGet]
        public Dictionary<string, DS014Result> DS014()
        {
            OracleConnection connection = new OracleConnection(ConnectionString);
            try
            {
                connection.Open();
                using (OracleCommand alterCmd = new OracleCommand("alter session set current_schema=eshell", connection))
                {
                    alterCmd.ExecuteNonQuery();
                }

                Dictionary<string, DS014Result> result = new Dictionary<string, DS014Result>();
                #region edi
                DS014Result edi = new DS014Result();

                using (OracleCommand cmd1 = new OracleCommand(@"select TO_CHAR(t.IT02_CRT_TIME, 'dd') iDay, count(*)
  from it02_incidant_base t
 where t.it02_ent_id = 10134
   and t.it02_status IN ('BD0906', 'BD0907')
   and TO_CHAR(t.IT02_CRT_TIME, 'yyyymm') =
       TO_CHAR(ADD_MONTHS(TRUNC(SYSDATE), -1), 'yyyymm')
   and t.it02_cls_id1='1f71606d20da4ca98b8eccf10dece383'
 group by TO_CHAR(t.IT02_CRT_TIME, 'dd')
 order by TO_CHAR(t.IT02_CRT_TIME, 'dd')", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd1);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    int days = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.AddMonths(-1).Month);
                    edi.lastmonth = new decimal[days];
                    for (int index = 0; index < edi.lastmonth.Length; index++)
                    {
                        edi.lastmonth[index] = 0;
                    }
                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        decimal Count1 = Convert.ToDecimal(dataTable.Rows[index][1]);
                        int iday = Convert.ToInt32(dataTable.Rows[index][0]);
                        edi.lastmonth[iday - 1] = Count1;
                    }
                }

                using (OracleCommand cmd1 = new OracleCommand(@"select TO_CHAR(t.IT02_CRT_TIME, 'dd') iDay, count(*)
  from it02_incidant_base t
 where t.it02_ent_id = 10134
   and t.it02_status IN ('BD0906', 'BD0907')
   and TO_CHAR(t.IT02_CRT_TIME, 'yyyymm') = TO_CHAR(SYSDATE, 'yyyymm')
   and t.it02_cls_id1='1f71606d20da4ca98b8eccf10dece383'
 group by TO_CHAR(t.IT02_CRT_TIME, 'dd')
 order by TO_CHAR(t.IT02_CRT_TIME, 'dd')", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd1);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);


                    int days = DateTime.Now.Day;// DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);
                    edi.thismonth = new decimal[days];
                    for (int index = 0; index < edi.thismonth.Length; index++)
                    {
                        edi.thismonth[index] = 0;
                    }
                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        decimal Count1 = Convert.ToDecimal(dataTable.Rows[index][1]);
                        int iday = Convert.ToInt32(dataTable.Rows[index][0]);
                        edi.thismonth[iday - 1] = Count1;
                    }
                }
                result.Add("edi", edi);
                #endregion

                #region financialSystem
                DS014Result financialSystem = new DS014Result();

                using (OracleCommand cmd1 = new OracleCommand(@"select TO_CHAR(t.IT02_CRT_TIME, 'dd') iDay, count(*)
  from it02_incidant_base t
 where t.it02_ent_id = 10134
   and t.it02_status IN ('BD0906', 'BD0907')
   and TO_CHAR(t.IT02_CRT_TIME, 'yyyymm') =
       TO_CHAR(ADD_MONTHS(TRUNC(SYSDATE), -1), 'yyyymm')
   and t.it02_cls_id1='12328b76089d4f4ea230a099bd97f3d1'
 group by TO_CHAR(t.IT02_CRT_TIME, 'dd')
 order by TO_CHAR(t.IT02_CRT_TIME, 'dd')", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd1);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    int days = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.AddMonths(-1).Month);
                    financialSystem.lastmonth = new decimal[days];
                    for (int index = 0; index < financialSystem.lastmonth.Length; index++)
                    {
                        financialSystem.lastmonth[index] = 0;
                    }
                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        decimal Count1 = Convert.ToDecimal(dataTable.Rows[index][1]);
                        int iday = Convert.ToInt32(dataTable.Rows[index][0]);
                        financialSystem.lastmonth[iday - 1] = Count1;
                    }
                }

                using (OracleCommand cmd1 = new OracleCommand(@"select TO_CHAR(t.IT02_CRT_TIME, 'dd') iDay, count(*)
  from it02_incidant_base t
 where t.it02_ent_id = 10134
   and t.it02_status IN ('BD0906', 'BD0907')
   and TO_CHAR(t.IT02_CRT_TIME, 'yyyymm') = TO_CHAR(SYSDATE, 'yyyymm')
   and t.it02_cls_id1='12328b76089d4f4ea230a099bd97f3d1'
 group by TO_CHAR(t.IT02_CRT_TIME, 'dd')
 order by TO_CHAR(t.IT02_CRT_TIME, 'dd')", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd1);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    int days = DateTime.Now.Day;
                    financialSystem.thismonth = new decimal[days];
                    for (int index = 0; index < financialSystem.thismonth.Length; index++)
                    {
                        financialSystem.thismonth[index] = 0;
                    }
                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        decimal Count1 = Convert.ToDecimal(dataTable.Rows[index][1]);
                        int iday = Convert.ToInt32(dataTable.Rows[index][0]);
                        financialSystem.thismonth[iday - 1] = Count1;
                    }
                }
                result.Add("financialSystem", financialSystem);
                #endregion

                #region dasktop
                DS014Result dasktop = new DS014Result();

                using (OracleCommand cmd1 = new OracleCommand(@"select TO_CHAR(t.IT02_CRT_TIME, 'dd') iDay, count(*)
  from it02_incidant_base t
 where t.it02_ent_id = 10134
   and t.it02_status IN ('BD0906', 'BD0907')
   and TO_CHAR(t.IT02_CRT_TIME, 'yyyymm') =
       TO_CHAR(ADD_MONTHS(TRUNC(SYSDATE), -1), 'yyyymm')
   and t.it02_cls_id1='567a12d84833452bbee1d69541d77223'
 group by TO_CHAR(t.IT02_CRT_TIME, 'dd')
 order by TO_CHAR(t.IT02_CRT_TIME, 'dd')", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd1);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    int days = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.AddMonths(-1).Month);
                    dasktop.lastmonth = new decimal[days];
                    for (int index = 0; index < dasktop.lastmonth.Length; index++)
                    {
                        dasktop.lastmonth[index] = 0;
                    }
                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        decimal Count1 = Convert.ToDecimal(dataTable.Rows[index][1]);
                        int iday = Convert.ToInt32(dataTable.Rows[index][0]);
                        dasktop.lastmonth[iday - 1] = Count1;
                    }
                }

                using (OracleCommand cmd1 = new OracleCommand(@"select TO_CHAR(t.IT02_CRT_TIME, 'dd') iDay, count(*)
  from it02_incidant_base t
 where t.it02_ent_id = 10134
   and t.it02_status IN ('BD0906', 'BD0907')
   and TO_CHAR(t.IT02_CRT_TIME, 'yyyymm') = TO_CHAR(SYSDATE, 'yyyymm')
   and t.it02_cls_id1='567a12d84833452bbee1d69541d77223'
 group by TO_CHAR(t.IT02_CRT_TIME, 'dd')
 order by TO_CHAR(t.IT02_CRT_TIME, 'dd')", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd1);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    int days = DateTime.Now.Day;
                    dasktop.thismonth = new decimal[days];
                    for (int index = 0; index < dasktop.thismonth.Length; index++)
                    {
                        dasktop.thismonth[index] = 0;
                    }
                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        decimal Count1 = Convert.ToDecimal(dataTable.Rows[index][1]);
                        int iday = Convert.ToInt32(dataTable.Rows[index][0]);
                        dasktop.thismonth[iday - 1] = Count1;
                    }
                }
                result.Add("dasktop", dasktop);
                #endregion

                #region event
                DS014Result @event = new DS014Result();

                using (OracleCommand cmd1 = new OracleCommand(@"select TO_CHAR(t.IT02_CRT_TIME, 'dd') iDay, count(*)
  from it02_incidant_base t
 where t.it02_ent_id = 10134
   and t.it02_status IN ('BD0906', 'BD0907')
   and TO_CHAR(t.IT02_CRT_TIME, 'yyyymm') =
       TO_CHAR(ADD_MONTHS(TRUNC(SYSDATE), -1), 'yyyymm')
 group by TO_CHAR(t.IT02_CRT_TIME, 'dd')
 order by TO_CHAR(t.IT02_CRT_TIME, 'dd')", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd1);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    int days = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.AddMonths(-1).Month);
                    @event.lastmonth = new decimal[days];
                    for (int index = 0; index < @event.lastmonth.Length; index++)
                    {
                        @event.lastmonth[index] = 0;
                    }
                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        decimal Count1 = Convert.ToDecimal(dataTable.Rows[index][1]);
                        int iday = Convert.ToInt32(dataTable.Rows[index][0]);
                        @event.lastmonth[iday - 1] = Count1;
                    }
                }

                using (OracleCommand cmd1 = new OracleCommand(@"select TO_CHAR(t.IT02_CRT_TIME, 'dd') iDay, count(*)
  from it02_incidant_base t
 where t.it02_ent_id = 10134
   and t.it02_status IN ('BD0906', 'BD0907')
   and TO_CHAR(t.IT02_CRT_TIME, 'yyyymm') = TO_CHAR(SYSDATE, 'yyyymm')
 group by TO_CHAR(t.IT02_CRT_TIME, 'dd')
 order by TO_CHAR(t.IT02_CRT_TIME, 'dd')", connection))
                {
                    OracleDataAdapter adapter = new OracleDataAdapter(cmd1);
                    DataTable dataTable = new DataTable();
                    adapter.Fill(dataTable);

                    int days = DateTime.Now.Day;
                    @event.thismonth = new decimal[days];
                    for (int index = 0; index < @event.thismonth.Length; index++)
                    {
                        @event.thismonth[index] = 0;
                    }
                    for (int index = 0; index < dataTable.Rows.Count; index++)
                    {
                        decimal Count1 = Convert.ToDecimal(dataTable.Rows[index][1]);
                        int iday = Convert.ToInt32(dataTable.Rows[index][0]);
                        @event.thismonth[iday - 1] = Count1;
                    }
                }
                result.Add("event", @event);
                #endregion
                return result;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (connection.State == System.Data.ConnectionState.Open)
                {
                    connection.Close();
                }
            }
        }
    }

    public class DS001LeftData
    {
        public NVItem[] leftData;
    }

    public class DS001RightData
    {
        public string[] ledgend;
        public decimal[] data;
    }

    public class DS002Result
    {
        public string 及时响应率;
        public string 及时解决率;
    }

    public class DS003Result
    {
        public string name;
        public decimal[] data;
    }

    public class DS004Result
    {
        public string[] xAxis;
        public decimal[] data1;
        public decimal[] data2;
        public decimal[] allCount;
    }
    public class DS005Result
    {
        public DS005Data 满意度;
    }
    public class DS005Data
    {
        public NVItem[] data;
    }

    public class NVItem
    {
        public string name;
        public decimal value;
    }

    public class DS006Result
    {
        public DS006Content 单量;
    }
    public class DS006Content
    {  
        public decimal 昨日事件单量;
        public decimal 今日事件单量;
    }
    public class DS007Result
    {
        public Dictionary<string, decimal> 事件处理流程;
    }
    public class DS008Result
    {
        public Left left;
        public Right right;

        public class Left
        {
            public decimal count;
            public string percent;
        }
        public class Right
        {
            public string product;
            public string operation;
        }
    }

    public class DS009Result
    {
        public decimal count;
        public decimal month;
        public decimal week;
    }
    public class DS011Result
    {
        public string[] ledgend;
        public decimal[] data1;
        public decimal[] data2;
        public decimal allCount;
    }

    public class DS014Result
    {
        public decimal[] lastmonth;
        public decimal[] thismonth;
    }
}
